package com.itheima.exerciseTest.method10_19.method17;

import java.text.Collator;
import java.util.Comparator;
import java.util.Locale;
import java.util.TreeMap;

public class StudentDemo {
    public static void main(String[] args) {
        TreeMap<Student, String> tm = new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student s1, Student s2) {
                int result = s1.getAge() - s2.getAge();
                if (result != 0)
                    return result;
                char c = s1.getName().charAt(0);
                boolean boo = false;
                if (c >= 'A' && c <= 'Z')
                    boo = true;
                else if (c >= 'a' && c <= 'z')
                    boo = true;

                if (boo == true) {
                    result = s1.getName().compareTo(s2.getName());
                    return result == 0 ? 1 : result;
                }
                Collator ins = Collator.getInstance(Locale.CHINESE);
                result = ins.compare(s1.getName(), s2.getName());
                return result == 0 ? 1 : result;
            }
        });

    }
}
